<template>
	<view class="app">
		<u-tabs :list="tags" :is-scroll="false" :current="current" @change="change" border-color="#55BB8A"></u-tabs>
		
		<view class="itemList">
			<view v-show="!list||list.length<1" class="nodata_view">暂无数据</view>
			<view class="item" v-bind:style="{ height: itemHeight + 'rpx' }" v-for="(item, index) in list" :key="index">
				<image src="/static/icon/point.png" class="item_icon"></image>
				<view class="item_body">
					<view class="item_line">
						<text class="line_left" v-if="current==0">转入数量</text>
						<text class="line_left" v-if="current==1">转出数量</text>
						<text class="line_left" v-if="current==2">兑换数量</text>
						<text class="line_num" v-if="current==0">+{{ item.quality }} </text>
						<text class="line_num" v-if="current==1">-{{ item.quality }} </text>
						<text class="line_num" v-if="current==2">-{{ item.quality }} </text>
					</view>
					<view class="item_line" v-if="current==2">
						<text class="line_left2">兑换金额</text>
						<text class="line_money" :class="gray">￥{{ item.money }}</text>
					</view>
					<view class="item_line">
						<text class="line_status">状态</text>
						<text v-if="current==0" class="line_msg" :class="{gray:item.status!=1}">{{item.status==1?'转入成功':'转入失败'}}</text>
						<text v-if="current==1" class="line_msg" :class="{gray:item.status!=1}">{{item.status==1?'转出成功':'转出失败'}}</text>
						<text v-if="current==2" class="line_msg" :class="{gray:item.status!=1}">{{item.status==1?'兑换成功':'兑换失败'}}</text>
					</view>
					<view class="item_line">
						<text class="line_date">{{ item.time  | date('y-mm-d h:M:s') }}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>

export default {
		data() {
			return {
				tags: [{name: '转入记录'}, {name: '转出记录'}, {name: '兑换记录'}],
				current: 0,
				itemHeight: 200,
				list:[]
			}
		},
		onLoad(options) {
			this.change(this.current);
		},
		methods: {
			async change(index) {
				uni.showLoading({title: '加载中'});
				
				this.list = [];
				this.current = index;
				if (this.current == 2) {
					this.itemHeight = 250;
				} else {
					this.itemHeight = 200;
				}
				//console.log(index);
				const res = await this.$request('wallet', 'flow', {
					type: this.current
				}, {
					showLoading: !this.loaded
				});
				uni.hideLoading();
				console.log("res="+ JSON.stringify(res));
				this.list = res.data;
			}
		}
	}
</script>

<style lang="scss"> 
	.itemList{
		padding: 30rpx;
	}
	
	.item{
		width: 100%;
		height: 200rpx;
		display: flex;
		flex-direction: row;
		margin-top: 44rpx;
	}
	
	.item_icon{
		width: 44rpx;
		height: 44rpx;
		margin-right: 20rpx;
	}
	
	.item_body{
		flex: 1;
		height: 100%;
		border-bottom: 1rpx solid #E2E2E2;
	}
	
	.item_line{
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		margin-bottom: 20rpx;
	}
	
	
	.line_left{
		font-size: 30rpx;
		font-weight: 400;
		line-height: 42rpx;
		color: #001C0F;
	}
	
	.line_left2{
		font-size: 26rpx;
		font-weight: 400;
		line-height: 42rpx;
		color: #001C0F;
	}
	
	.line_num{
		font-size: 34rpx;
		font-weight: 800;
		line-height: 48rpx;
		color: #001C0F;
	}
	
	.line_status{
		font-size: 26rpx;
		font-weight: 400;
		line-height: 37rpx;
		color: #8F8F8F;
		opacity: 1;
	}
	
	
	.line_msg{
		font-size: 26rpx;
		font-weight: 400;
		line-height: 37rpx;
		opacity: 1;
		color: #55BB8A;
		&.gray{
			color: #fa3534;
		}
	}
	
	.line_money{
		font-size: 26rpx;
		font-weight: 400;
		line-height: 37rpx;
		opacity: 1;
		color: red;
		&.gray{
			color: red;
		}
	}
	
	.line_date{
		font-size: 22rpx;
		line-height: 30rpx;
		color: #8F8F8F;
		opacity: 1;
	}
	.nodata_view{
		width: 100%;
		height: 500rpx;
		display: flex;
		align-items: center;
		justify-content: center;		
	}

	
</style>

